import { ChangeDetectionStrategy, Component } from '@angular/core';

import { FilePdfService } from './pdf.service';

@Component({
  selector: 'file-pdf',
  templateUrl: './pdf.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class FilePdfComponent {
  constructor(private docxSrv: FilePdfService) {}

  async output(): Promise<void> {
    const doc = await this.docxSrv.instance;
    doc.text(20, 20, 'Hello world!');
    doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
    doc.addImage(
      '',
      'PNG',
      20,
      40,
      100,
      100
    );
    doc.addPage();
    doc.setTextColor(150);
    doc.text(20, 20, 'Do you like that?');
    doc.save('output.pdf');
  }
}
